home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0833.dms / q0833.adf / CalenderMacros / calendar.fw3 < prev    next >
Text File  |  1997-04-10  |  13KB  |  371 lines

  1. /* Calendar macro for FinalWriter (SoftWood)
  2.    Written by Andrew McCardie
  3.    amethyst@gulf.net
  4.    January 31st, 1995
  5.    $VER: FW Calendar Macro v1.1 for FW3
  6.  
  7.    Because of changes in measurement of text blocks in FW3, this macro
  8.    will probably not work under previous versions of FW.
  9.  
  10.    This macro can create three different types of calendars: Portrait,
  11.    double-portrait, and landscape.  It supports all years that are
  12.    supported by the Amiga's internal calendar (1978 ->)  
  13.  
  14.    Portrait produces a standard 8.5x11 page with a single calendar.
  15.    Double portrait produces a standard 8.5x11 page with two calendars.
  16.    Landscape produces a standard 11x8.5 page with a single calendar.
  17.  
  18.    While it should handle leap-years, this feature has not been
  19.    exhaustively tested.  The fonts and margins are designed to be
  20.    user-customizeable.  Certain default values (in inches) have been
  21.    hardcoded into the variables 'top_margin', 'bottom_margin', and 
  22.    'side_margin' to produce the largest calendars on my DeskJet.  You
  23.    can change these if you need a smaller calendar or if the calendars
  24.    print incorrectly on your setup.
  25.  
  26.    If you change the default fonts, you may have to experiment with their
  27.    sizes and widths to get an appropriate look.
  28.  
  29.    If you find any bugs, let me know and I'll try to rectify them.
  30.  
  31.    Disclaimer: I take no responsibility for problems that may result from using
  32.                this macro.  
  33. */
  34.  
  35. OPTIONS RESULTS
  36. ADDRESS "FINALW.1"
  37. ClearDoc FORCE
  38. View 25  /* Speeds things up slightly on fast machines, probably more on
  39.           slower machines.
  40.         */
  41. SetMeasure MicroPoints
  42. BoxPrefs LINEWT 2 LINECOLOR Black FILL Solid FILLCOLOR Cyan TEXTFLOW None
  43.  
  44. TextBlockPrefs TEXTFLOW None
  45.  
  46. micropoints_per_inch = 720
  47.  
  48. ShowMessage 1 0 '"What type of calendar?" "" "" "Portrait" "Double-Portrait" "Landscape"'
  49. calendar_type = RESULT
  50.  
  51. Select
  52.  
  53.     /*  Portrait calendar  */
  54.    When calendar_type = 1 Then
  55.       Do
  56.          PageSetup PAGETYPE USLetter ORIENT Tall
  57.          GetPageSetup WIDTH HEIGHT
  58.             Parse Var RESULT true_width true_height
  59.  
  60.             /* The following measurements are based on inches converted to micropoints
  61.                Experiment with the defaults at your own risk, however. :) */
  62.  
  63.             side_margin = Trunc(.5 * micropoints_per_inch)
  64.             top_margin = Trunc(.625 * micropoints_per_inch)
  65.             bottom_margin = Trunc(.625 * micropoints_per_inch)
  66.             pagewidth = Trunc(true_width - 2 * side_margin)
  67.             pageheight = Trunc(true_height - top_margin - bottom_margin)
  68.             text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
  69.             box_width = Trunc(pagewidth/7)
  70.             box_height = Trunc((pageheight-text_area)/5)
  71.             bevel_control = "BEVEL"
  72.             SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
  73.  
  74.             /* Set up font defaults */
  75.             datestring_font = "Dragon_BoldItalic"
  76.             datestring_font_size = 64
  77.             datestring_font_width = 100
  78.             text_font = "Dragon_BoldItalic"
  79.             text_font_size = 20
  80.             text_font_width = 80
  81.             day_font = "Dragon_Bold"
  82.             day_font_size = 20
  83.             day_font_width = 100
  84.  
  85.          iteration = 1
  86.         End
  87.  
  88.     /*  Double-portrait calendar  */
  89.    When calendar_type == 2 Then
  90.       Do
  91.          PageSetup PAGETYPE USLetter ORIENT Tall
  92.          GetPageSetup WIDTH HEIGHT
  93.             Parse Var RESULT true_width true_height
  94.  
  95.             /* The following measurements are based on inches converted to micropoints
  96.                Experiment with the defaults at your own risk, however. :) */
  97.  
  98.             side_margin = Trunc(.5 * micropoints_per_inch)
  99.             top_margin = Trunc(.625 * micropoints_per_inch)
  100.             bottom_margin = Trunc(5.50 * micropoints_per_inch)
  101.             pagewidth = Trunc(true_width - 2 * side_margin)
  102.             pageheight = Trunc(true_height - top_margin - bottom_margin)
  103.             text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
  104.             box_width = Trunc(pagewidth/7)
  105.             box_height = Trunc((pageheight-text_area)/5)
  106.             bevel_control = "BEVEL"
  107.             SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
  108.  
  109.             /* Set up font defaults */
  110.             datestring_font = "Dragon_BoldItalic"
  111.             datestring_font_size = 29
  112.             datestring_font_width = 150
  113.             text_font = "Dragon_BoldItalic"
  114.             text_font_size = 18
  115.             text_font_width = 80
  116.             day_font = "Dragon_Bold"
  117.             day_font_size = 20
  118.             day_font_width = 100
  119.  
  120.          iteration = 2
  121.       End
  122.  
  123.     /*  Landscape calendar  */
  124.    When calendar_type == 3 Then
  125.       Do
  126.          PageSetup PAGETYPE USLetter ORIENT Wide
  127.          GetPageSetup WIDTH HEIGHT
  128.             Parse Var RESULT true_width true_height
  129.  
  130.             /* The following measurements are based on inches converted to micropoints
  131.                Experiment with the defaults at your own risk, however. :) */
  132.  
  133.             side_margin = Trunc(.5 * micropoints_per_inch)
  134.             top_margin = Trunc(.625 * micropoints_per_inch)
  135.             bottom_margin = Trunc(.625 * micropoints_per_inch)
  136.             pagewidth = Trunc(true_width - 2 * side_margin)
  137.             pageheight = Trunc(true_height - top_margin - bottom_margin)
  138.             text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
  139.             box_width = Trunc(pagewidth/7)
  140.             box_height = Trunc((pageheight-text_area)/5)
  141.             bevel_control = "BEVEL"
  142.             SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
  143.  
  144.             /* Set up font defaults */
  145.             datestring_font = "Montreal_BoldItalic"
  146.             datestring_font_size = 44
  147.             datestring_font_width = 150
  148.             text_font = "Montreal_BoldItalic"
  149.             text_font_size = 22
  150.             text_font_width = 80
  151.             day_font = "Montreal_Bold"
  152.             day_font_size = 20
  153.             day_font_width = 100
  154.  
  155.          iteration = 1
  156.       End
  157. End
  158.  
  159. current_month = -1
  160. current_month_number = -1
  161. current_year = -1
  162.  
  163. temp_date = "00000000"
  164.  
  165. day.6 = 'Saturday'
  166. day.0 = 'Sunday'
  167. day.1 = 'Monday'
  168. day.2 = 'Tuesday'
  169. day.3 = 'Wednesday'
  170. day.4 = 'Thursday'
  171. day.5 = 'Friday'
  172.  
  173. month.0  = 'January'
  174. month.1  = 'February'
  175. month.2  = 'March'
  176. month.3  = 'April'
  177. month.4  = 'May'
  178. month.5  = 'June'
  179. month.6  = 'July'
  180. month.7  = 'August'
  181. month.8  = 'September'
  182. month.9  = 'October'
  183. month.10 = 'November'
  184. month.11 = 'December'
  185.  
  186. month_length.0  = 31
  187. month_length.1  = 28
  188. month_length.2  = 31
  189. month_length.3  = 30
  190. month_length.4  = 31
  191. month_length.5  = 30
  192. month_length.6  = 31
  193. month_length.7  = 31
  194. month_length.8  = 30
  195. month_length.9  = 31
  196. month_length.10 = 30
  197. month_length.11 = 31
  198.  
  199. RequestText '"Month Select" "Month:" 'DATE('M')''
  200. current_month = RESULT
  201.  
  202. RequestText '"Year Select" "Year:" 'SUBSTR(DATE('S'),1,4)''
  203. current_year = RESULT
  204. if current_year < 1978 then current_year = 1978
  205.  
  206. Do i = 0 to 11
  207.    If current_month = month.i Then current_month_number = i + 1
  208. End
  209.  
  210. Do While iteration > 0
  211.  
  212.    If current_year//4 == 0 & current_year//100 > 0 Then
  213.       month_length.1 = 29
  214.    Else
  215.       If current_year//400 == 0 Then
  216.          month_length.1 = 29
  217.  
  218.    Select
  219.       When current_month_number < 10 Then
  220.          temp_date = current_year || 0 || current_month_number || "01"
  221.       When current_month_number >= 10 Then
  222.          temp_date = current_year || current_month_number || "01"
  223.        When current_month_number == -1 Then
  224.          Exit 10
  225.    End
  226.  
  227.    first_day_of_the_month = Date('W', temp_date, 'S')
  228.  
  229.    Select
  230.       When first_day_of_the_month == "Saturday" Then cal_start = 6
  231.       When first_day_of_the_month == "Sunday" Then cal_start = 0
  232.       When first_day_of_the_month == "Monday" Then cal_start = 1
  233.       When first_day_of_the_month == "Tuesday" Then cal_start = 2
  234.       When first_day_of_the_month == "Wednesday" Then cal_start = 3
  235.       When first_day_of_the_month == "Thursday" Then cal_start = 4
  236.       When first_day_of_the_month == "Friday" Then cal_start = 5
  237.    End
  238.  
  239.    /*  Create month/year header  */
  240.    TextBlockTypePrefs SIZE datestring_font_size WIDTH datestring_font_width FONT datestring_font
  241.    datestring = current_month || " " || current_year
  242.    obj_top = top_margin + datestring_font_size * 9
  243.    DrawTextBlock 1 side_margin obj_top datestring
  244.    datestring_obj = RESULT
  245.    Redraw    
  246.    GetObjectCoords datestring_obj
  247.    coords = RESULT
  248.    Parse Var coords Page obj_left obj_top obj_width obj_height
  249.    text_edge = Trunc(side_margin + (pagewidth - obj_width)/2)
  250.    SetObjectCoords datestring_obj Page text_edge obj_top obj_width obj_height
  251.     
  252.    i = 0
  253.    Do While (i < 7)
  254.       j = 0
  255.       box_left = side_margin+box_width*i
  256.       box_top = top_margin+text_area
  257.         
  258.       Do While (j < 5)
  259.          serial_position = i + (j * 7)
  260.          index = current_month_number - 1
  261.          If serial_position >= cal_start & serial_position < cal_start+month_length.index
  262.             Then BoxPrefs LINEWT 2 LINECOLOR Black FILL Transparent TEXTFLOW None
  263.          Else BoxPrefs LINEWT 2 LINECOLOR Black FILL Solid FILLCOLOR Cyan TEXTFLOW None
  264.          box_top  = top_margin+text_area+box_height*j
  265.          text_top = box_top + box_height - day_font_size * 5
  266.          DrawBox Page box_left box_top box_width box_height bevel_control
  267.          box_obj.i.j = RESULT
  268.          day_of_month = serial_position-cal_start+1
  269.          TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
  270.          GetBoxPrefs FILL
  271.          If RESULT = "Transparent" Then
  272.             Do
  273.                 DrawTextBlock Page box_left text_top day_of_month
  274.                 day_obj = RESULT
  275.                 Redraw
  276.                 GetObjectCoords day_obj
  277.                 coords = RESULT
  278.                 Parse Var coords Page obj_left obj_top obj_width obj_height
  279.                 text_edge = Trunc(box_left + (box_width - obj_width - 50))
  280.                 SetObjectCoords day_obj Page text_edge text_top obj_width obj_height
  281.             End         
  282.          j = j + 1
  283.       End
  284.       
  285.       i = i + 1
  286.    End
  287.  
  288.     i = 0
  289.     Do While (i < 7)
  290.         GetObjectCoords box_obj.i.0
  291.         coords = RESULT
  292.         Parse Var coords Page obj_left obj_top obj_width obj_height
  293.         box_center = Trunc(obj_left + obj_width/2)
  294.         box_top = obj_top
  295.         TextBlockTypePrefs SIZE text_font_size WIDTH text_font_width FONT text_font
  296.         DrawTextBlock 1 obj_left obj_top day.i
  297.         text_obj.i = RESULT
  298.         Redraw
  299.         GetObjectCoords text_obj.i
  300.         coords = RESULT
  301.         Parse Var coords Page obj_left obj_top obj_width obj_height
  302.         text_edge = Trunc(box_center - obj_width/2)
  303.         text_bottom = box_top-text_font_size*5
  304.         SetObjectCoords text_obj.i Page text_edge text_bottom obj_width obj_height
  305.         i = i + 1
  306.     End
  307.  
  308.  
  309.     /* Special cases for months whose last day(s) wrap to the 
  310.        beginning of the week */
  311.  
  312.    If cal_start+month_length.index == 36 Then
  313.       Do
  314.          TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
  315.          day_of_month = day_of_month + 1
  316.          GetObjectCoords box_obj.0.4
  317.          coords = RESULT
  318.          Parse Var coords Page obj_left obj_top obj_width obj_height
  319.          DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
  320.          DrawTextBlock 1 obj_left+50 obj_top+day_font_size*12 day_of_month
  321.          
  322.       End
  323.    If cal_start+month_length.index == 37 Then
  324.       Do
  325.          TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
  326.          day_of_month = day_of_month + 1
  327.          GetObjectCoords box_obj.0.4
  328.          coords = RESULT
  329.          Parse Var coords Page obj_left obj_top obj_width obj_height
  330.          DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
  331.          DrawTextBlock 1 obj_left+50 obj_top+day_font_size*12 day_of_month
  332.          
  333.          day_of_month = day_of_month + 1
  334.          GetObjectCoords box_obj.1.4
  335.          coords = RESULT
  336.          Parse Var coords Page obj_left obj_top obj_width obj_height
  337.          DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
  338.          DrawTextBlock 1 obj_left+50 obj_top+day_font_size*12 day_of_month
  339.       End
  340.  
  341.    /*  Handles special case of double portrait calendar  */
  342.     If iteration == 2 Then
  343.       Do
  344.          drop datestring
  345.          top_margin = Trunc(5.5 * micropoints_per_inch)
  346.          bottom_margin = Trunc(.625 * micropoints_per_inch)
  347.          pagewidth = Trunc(true_width - 2 * side_margin)
  348.          pageheight = Trunc(true_height - top_margin - bottom_margin)
  349.          text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
  350.          box_width = Trunc(pagewidth/7)
  351.          box_height = Trunc((pageheight-text_area)/5)
  352.          If current_month_number < 12 Then
  353.             Do
  354.                current_month = month.current_month_number
  355.                current_month_number = current_month_number + 1
  356.             End
  357.          Else
  358.             Do
  359.                current_month_number = 1
  360.                current_month = "January"
  361.                current_year = current_year + 1
  362.             End
  363.       End
  364.     iteration = iteration - 1
  365. End
  366.  
  367. SectionSetup BOTTOM bottom_margin
  368. SelectObject
  369. Redraw
  370. View 50
  371.